package com.heima.common.exception;


import com.heima.common.dto.ResponseResult;
import com.heima.common.enums.AppHttpCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class BaseExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseResult handlerException(Exception e) {

        //打印日志
      log.info("全局异常捕获：{}",e.getMessage());

      //返回异常结果
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

}
